#include "Core/GUI/IWidget.h"
#include "Core/GUI/Application/IWindow.h"
#include "Core/GUI/Button/IButton.h"
#include "GUIManager.h"

namespace GUI
{
	namespace Win32
	{

		Core::GUI::IWidget* GUIManager::GetWidget(HWND _hWnd, Core::GUI::WidgetType _type) const
		{
			auto it = m_hWidgets.find(_hWnd);
			if (it != std::end(m_hWidgets) && it->second->GetType() == _type)
			{
				return it->second;
			}
			return NULL;
		}

		Core::GUI::IWindow * GUIManager::GetWindow(HWND _hWnd) const
		{
			return (Core::GUI::IWindow*)GetWidget(_hWnd, Core::GUI::Window);
		}

		Core::GUI::IButton * GUIManager::GetButton(HWND _hWnd) const
		{
			return (Core::GUI::IButton*)GetWidget(_hWnd, Core::GUI::Button);
		}
	}
}